// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class ORDER_GENERAL_OML_O21 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("44 CONTAINER_1",44)]
  	    [HL7Field(HL7Version.v24, 44, HL7Repeat.False, HL7Required.False,"CONTAINER_1_OML_O21")]
	    public CONTAINER_1_OML_O21 CONTAINER_1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("52 ORDER",52)]
  	    [HL7Field(HL7Version.v24, 52, HL7Repeat.True, HL7Required.True,"ORDER_OML_O21")]
	    public ORDER_OML_O21[] ORDER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("92 PRIOR_RESULT",92)]
  	    [HL7Field(HL7Version.v24, 92, HL7Repeat.False, HL7Required.False,"PRIOR_RESULT_OML_O21")]
	    public PRIOR_RESULT_OML_O21 PRIOR_RESULT {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			CONTAINER_1 = ProcessGroup<CONTAINER_1_OML_O21>(availableData, options, "CONTAINER_1");
			ORDER = ProcessGroupArray<ORDER_OML_O21>(availableData, options, "ORDER");
			PRIOR_RESULT = ProcessGroup<PRIOR_RESULT_OML_O21>(availableData, options, "PRIOR_RESULT");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			CONTAINER_1_OML_O21 testCONTAINER_1_OML_O21 = new CONTAINER_1_OML_O21();
			bool grpCCCONTAINER_1_OML_O21 = (testCONTAINER_1_OML_O21.CanConsume(availableData, options));
			if (IsRequired("CONTAINER_1", options.Version) || grpCCCONTAINER_1_OML_O21) {
				return grpCCCONTAINER_1_OML_O21;
			}
			ORDER_OML_O21 testORDER_OML_O21 = new ORDER_OML_O21();
			bool grpCCORDER_OML_O21 = (testORDER_OML_O21.CanConsume(availableData, options));
			if (IsRequired("ORDER", options.Version) || grpCCORDER_OML_O21) {
				return grpCCORDER_OML_O21;
			}
			PRIOR_RESULT_OML_O21 testPRIOR_RESULT_OML_O21 = new PRIOR_RESULT_OML_O21();
			bool grpCCPRIOR_RESULT_OML_O21 = (testPRIOR_RESULT_OML_O21.CanConsume(availableData, options));
			if (IsRequired("PRIOR_RESULT", options.Version) || grpCCPRIOR_RESULT_OML_O21) {
				return grpCCPRIOR_RESULT_OML_O21;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "ORDER_GENERAL";
			}
        }

        static ORDER_GENERAL_OML_O21() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(ORDER_GENERAL_OML_O21));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (CONTAINER_1 != null) {
			string segmentValue = CONTAINER_1.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ORDER != null && ORDER.Length > 0) {
			for (int i = 0; i < ORDER.Length; i++) {
				string segmentValue = ORDER[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
		 if (PRIOR_RESULT != null) {
			string segmentValue = PRIOR_RESULT.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

